/*
 * @Description: vue types
 * @Author: seadon
 * @LastEditors: seadon
 * @Date: 2021-07-07 10:33:49
 * @LastEditTime: 2021-07-07 10:42:55
 */
import { CSSProperties } from 'vue'
import { createTypes, VueTypeValidableDef, VueTypesInterface } from 'vue-types'
import { tuple, VueNode } from './type'

const PropTypes = createTypes({
	func: undefined,
	bool: undefined,
	string: undefined,
	number: undefined,
	array: undefined,
	object: undefined,
	integer: undefined,
})

PropTypes.extend([
	{
		name: 'looseBool',
		getter: true,
		type: Boolean,
		default: undefined,
	},
	{
		name: 'style',
		getter: true,
		type: [String, Object],
		default: undefined,
	},
	{
		name: 'VNodeChild',
		getter: true,
		type: undefined,
	},
])

export function withUndefined<T extends { default?: any }>(type: T): T {
	type.default = undefined
	return type
}

export const ButtonTypes = tuple(
	'default',
	'primary',
	'ghost',
	'dashed',
	'danger',
	'link'
)

export default PropTypes as VueTypesInterface & {
	readonly looseBool: VueTypeValidableDef<boolean>
	readonly style: VueTypeValidableDef<CSSProperties>
	readonly VNodeChild: VueTypeValidableDef<VueNode>
}

export * from './type'
